<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>电子发票申请详情</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">

<div class="Wrapper">
    <div>
    <div id="pageInTab" class="pageInTab">
        <form id="cust_elecInvoice_add_form">
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_33">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <span id="cstNm" name="cstNm"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">项目所属机构</div>
                    <div class="field">
                        <span id="orgNm" name="orgNm"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">发票流水号</div>
                    <div class="field">
                        <span id="serialNum" name="serialNum"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">客户类型</div>
                    <div class="field">
                        <span id="cstTypNm" name="cstTypNm"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">申请人</div>
                    <div class="field">
                        <span id="applyNm" name="applyNm"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">开票方式</div>
                    <div class="field">
                        <span id="billWayCd" name="billWayCd">电子发票</span>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">版本文件下载地址</div>
                    <div class="field">
                        <span id="downloadUrl" name="downloadUrl"></span>
                        <c:if test="${'1' == isGetUrl}">
                            <span id="getDownloadUrl" name="getDownloadUrl">
                                <a href="javascript:getDownloadUrl()"><font style="color:#6495ED;">重新获取</font></a>
                            </span>
                        </c:if>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">发票抬头</div>
                    <div class="field">
                        <span id="invTitle" name="invTitle"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">纳税人识别号</div>
                    <div class="field">
                        <span id="invTaxId" name="invTaxId"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">联系电话</div>
                    <div class="field">
                        <span id="phone" name="phone"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">电子邮箱</div>
                    <div class="field">
                        <span id="email" name="email"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">实收金额合计</div>
                    <div class="field">
                        <span id="paidUpAmt" name="paidUpAmt"></span>
                    </div>
                </div>
            </div>
        </form>
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>支付表信息</span>
            </div>
            <!-- 支付表列表 -->
            <jsp:include page="invoiceBscGrid.jsp" flush="true"></jsp:include>
        </div>
        <div class="btnsBox" style="text-align: center">
            <c:if test="${'1' == billWayCd}">
                <span id="revertInvoice" class="sq-button sq-button-round" onclick="revertInvoice4Elec()">冲红</span>
            </c:if>
        </div>
    </div>
</div>
</div>
<script>
    var applyId = '${applyId}';
    var bscInfoId = '${bscInfoId}';
    $(function () {
        initData();
        initGrid();
    });

    function getDownloadUrl() {
        var url = "<%=path%>/invoice/electron/getDownloadUrl.do";
        $.ligerDialog.confirm('是否重新获取电子发票文件下载地址?', function (flag) {
            if (flag == false) return;
            AjaxUtils.ajaxPost(url, {bscInfoId: bscInfoId}, getDownloadUrlCallback);
        });
    }

    function getDownloadUrlCallback(msg) {
        if (msg.success == 1) {
            $("#downloadUrl").html(msg.data);
        } else {
            UIUtils.alertError(msg.info);
        }
    }

    //查看支付表详情
    function detailBtn(id, paySchId) {
        var editFlag = true;
        Add_navTab('tab_prj_quat_prps' + id, '查看支付表', '<%=path%>/project/prjprdpayschm/toPrjPrdPaySchMDetailPageBySchId.do?paySchId=' + paySchId);
    }

    //修改初始化数据
    function initData() {
        if (!applyId) return;
        var _url = '<%=path%>/invoice/prjbillapply/getById.do';
        AjaxUtils.ajaxGet(_url, {id: applyId}, initCallback);
    }

    //初始化回调
    function initCallback(msg) {
        if (msg.success == 1) {
            setData(msg.data);//设置数据
        } else {
            UIUtils.alertError(msg.info);
        }
    }

    frameElement.dialog.onCancel = function () {
        frameElement.dialog.close();
    }

    //修改时候设置页面数据
    function setData(data) {
        $("#serialNum").html(data.serialNum);
        $("#cstNm").html(data.cstNm);
        $("#cstTypNm").html(data.cstTypNm);
        $("#orgNm").html(data.buOrgCdNm);
        $("#applyNm").html(data.applyNm);
        $("#downloadUrl").html(data.downloadUrl);
        $("#invTaxId").html(data.invTaxId);
        $("#invTitle").html(data.invTitle);
        $("#phone").html(data.invTel);
        $("#email").html(data.email);
        $("#paidUpAmt").html(data.paidUpAmt / 100);
    };

    function revertInvoice4Elec() {
        $.ligerDialog.confirm('是否确认冲红电子发票?', function (flag) {
            if (flag == false) return;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {},
                url: '<%=path%>/invoice/electron/revertInvoice.do',
                success: function (msg) {
                    if (msg.success == 1) {

                    } else {

                    }
                }
            });
        });
    }
</script>

</body>
</html>